package com.sunlands.zlcx.usercenter.repository;

import com.sunlands.zlcx.usercenter.domain.UsersTargetRelationDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;


/**
 * @author anjl
 * @date 1:30 PM 2019/4/15
 * description:
 */
@Repository
public interface UsersTargetRepository extends JpaRepository<UsersTargetRelationDO, Long> {

    UsersTargetRelationDO findByUserIdAndStatus(Long userId, Integer status);

    @Query(value = "select sum(study_hours) from tz_user_target_relation  p where p.user_id = ?1 ", nativeQuery = true)
    BigDecimal sumStudyHours(Long userId);
}

